from flask import Flask,current_app
from flask_cors import CORS
from config.myconfig import myconfig
from project.group_bp import group_bp
from project.company import bp_company
import logging
from logging import FileHandler
import datetime



def create_app():
    app = Flask(__name__)
    app.config.from_object(myconfig)
    app.register_blueprint(group_bp)
    app.register_blueprint(bp_company)

    CORS(app)
    with app.app_context():
        pass
    return app
app = create_app()

if __name__ == '__main__':
    filename = datetime.datetime.now().strftime("%Y%m")
    handler = logging.FileHandler('logs/'+filename+".txt")
    app.logger.addHandler(handler)
    app.run(debug=True)